package 结构型模式.代理;

/**
 * @ClassNameWineProxyTest
 * @Description
 * @Author
 * @Date2021/12/7 20:10
 **/
public class WineProxyTest {
    public static void main(String[] args) {

        WineProxyStore wineProxyStore = new WineProxyStore();
        wineProxyStore.sell();
    }
}


interface WineFactory {
    // 抽象工厂厂家卖酒
    void sell();
}

class WineFactoryImpl implements WineFactory {

    @Override
    public void sell() {
        System.out.println("厂家真正卖酒");
    }
}


class WineProxyStore implements WineFactory {

    private WineFactoryImpl wineFactory;


    @Override
    public void sell() {

        if (wineFactory == null) {
            wineFactory = new WineFactoryImpl();
        }
        preSell();
        wineFactory.sell();
        postSell();
    }

    private void postSell() {
        System.out.println("代理商返点");
    }

    private void preSell() {
        System.out.println("代理商包装");
    }
}
